package net.wofly.cashier.reservation.validator;

import net.wofly.cashier.reservation.domain.Reservation;
import org.apache.commons.lang3.StringUtils;

public class ReservationValidator {

    /**
     * 换行符
     */
    private static String lineSeparator = System.getProperty("line.separator");

    public static String validateGetCartListParams(String userID) {
        StringBuffer stringBuffer = new StringBuffer();
        if (StringUtils.isBlank(userID)) {
            stringBuffer.append("用户ID不能为空").append(lineSeparator);
        }
        return stringBuffer.toString();
    }

    public static String validateAddReservationParams(Reservation reservation) {
        StringBuffer stringBuffer = new StringBuffer();
        if (reservation == null) {
            stringBuffer.append("预约定位信息不能为空").append(lineSeparator);
        } else {
            if (StringUtils.isBlank(reservation.getName())) {
                stringBuffer.append("客户姓名不能为空").append(lineSeparator);
            }

//            if (StringUtils.isBlank(reservation.getEmployeeID())) {
//                stringBuffer.append("操作员工ID不能为空").append(lineSeparator);
//            }

            if (reservation.getReservationMealTime() == null) {
                stringBuffer.append("预约就餐时间不能为空").append(lineSeparator);
            }

            if (StringUtils.isBlank(reservation.getMobile())) {
                stringBuffer.append("客户电话不能为空").append(lineSeparator);
            }
        }

        return stringBuffer.toString();
    }

    public static String validateCancelReservationParams(String reservationID, String employeeID) {
        StringBuffer stringBuffer = new StringBuffer();
        if (StringUtils.isBlank(reservationID)) {
            stringBuffer.append("预定ID不能为空").append(lineSeparator);
        }

        if (StringUtils.isBlank(employeeID)) {
            stringBuffer.append("操作员工ID不能为空").append(lineSeparator);
        }

        return stringBuffer.toString();
    }

    public static String validateGetAllReservationParams(String employeeID, Long reservationMealTime, Integer reservationMealType) {
        StringBuffer stringBuffer = new StringBuffer();
        return stringBuffer.toString();
    }

    public static String validateRepastParams(String reservationID, String employeeID) {
        StringBuffer stringBuffer = new StringBuffer();
        if (StringUtils.isBlank(reservationID)) {
            stringBuffer.append("预定ID不能为空").append(lineSeparator);
        }

        if (StringUtils.isBlank(employeeID)) {
            stringBuffer.append("操作员工ID不能为空").append(lineSeparator);
        }

        return stringBuffer.toString();
    }

    public static String validateUpdateReservationParams(Reservation reservation) {
        StringBuffer stringBuffer = new StringBuffer();
        if (reservation == null) {
            stringBuffer.append("预约定位信息不能为空").append(lineSeparator);
        } else {

            if (StringUtils.isBlank(reservation.getReservationID())) {
                stringBuffer.append("预定ID不能为空").append(lineSeparator);
            }

            if (StringUtils.isBlank(reservation.getName())) {
                stringBuffer.append("客户姓名不能为空").append(lineSeparator);
            }

//            if (StringUtils.isBlank(reservation.getEmployeeID())) {
//                stringBuffer.append("操作员工ID不能为空").append(lineSeparator);
//            }

            if (reservation.getReservationMealTime() == null) {
                stringBuffer.append("预约就餐时间不能为空").append(lineSeparator);
            }

            if (reservation.getMobile() == null) {
                stringBuffer.append("客户电话不能为空").append(lineSeparator);
            }
        }

        return stringBuffer.toString();
    }
}
